package com.hiwhitley.himei.module.video;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hiwhitley.himei.R;
import com.hiwhitley.himei.contract.FindMoreContract;
import com.hiwhitley.himei.contract.model.FindMoreModel;
import com.hiwhitley.himei.contract.presenter.FindMorePresenter;
import com.hiwhitley.himei.entity.FindMore;
import com.hiwhitley.himei.mvpframe.base.BaseFrameFragment;
import com.hiwhitley.himei.network.HttpAdress;

import java.util.List;

import butterknife.BindView;
import me.drakeet.multitype.MultiTypeAdapter;

/**
 * Created by hiwhitley on 2016/9/24.
 */

public class FindMoreFragment extends BaseFrameFragment<FindMorePresenter, FindMoreModel> implements FindMoreContract.View {

    @BindView(R.id.find_more_recycler_view)
    RecyclerView mFindMoreRecyclerView;

    private static final String TAG = "FindMoreFragment";
    private MultiTypeAdapter mMultiTypeAdapter;

    public static FindMoreFragment newInstance() {
        return new FindMoreFragment();
    }

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_find_more;
    }

    @Override
    protected void init() {
        mPresenter.loadFindMore(HttpAdress.FIND_MORE);
    }

    @Override
    protected void setListener() {

        mMultiTypeAdapter = new MultiTypeAdapter();
        mMultiTypeAdapter.register(FindMore.class, new FindMoreViewProvider());

        mFindMoreRecyclerView.setHasFixedSize(true);
        mFindMoreRecyclerView.setLayoutManager(new GridLayoutManager(mActivity, 2));
        mFindMoreRecyclerView.setAdapter(mMultiTypeAdapter);
    }

    @Override
    public void showFindMoreView(List<FindMore> moreList) {

        mMultiTypeAdapter.setItems(moreList);
        mMultiTypeAdapter.notifyDataSetChanged();
    }

    @Override
    public void onRequestStart() {

    }

    @Override
    public void onRequestEnd() {

    }
}
